package com.py.credit.controller;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSON;
import com.py.credit.common.rest.RestServiceResult;
import com.py.credit.service.MessDataService;
import com.py.framework.core.helper.HttpServletHelper;
import com.py.framework.core.utils.SerializingUtil;

/**
 * 联合奖惩规则controller
 */
@RestController
@RequestMapping(value = "/messData")
public class MessDataController {

    private final static String FRONT_TABLE_CJGZ_ID = "messData";

    private final static String FRONT_TABLE_JLGZ_ID = "jlgz";

    @Autowired
    private MessDataService messDataService;


    @Value("${absolutepath}")
    private String absolutepath;

    
    /**
	 * @api {post} /auth/getMessDataForInit.do 获取联合奖惩信息
	 * @apiName getOfficeById
	 * @apiVersion 0.0.1
	 * @apiGroup 对外接口 
	 * @apiParam {HttpServletRequest} request 请求实例
	 * @apiParam {long} officeId 部门Id
	 * @apiParamExample {json} 请求参数示例
	 *  {}
	 * @apiSuccess {String} code 状态码:0 成功 -1 失败
	 * @apiSuccess {String} msg 错误信息
	 * @apiSuccess {int} count 结果集数据量
	 * @apiSuccess {String} data 结果集
	 * @apiSuccess {String} officeName 部门名称
	 * @apiSuccess {String} officeCode 部门编码
	 * @apiSuccess {long} parentId 父节点ID
	 * @apiSuccess {long} areaId 区域ID
	 * @apiSuccess {int} orderBy 排序
	 * @apiSuccess {String} areaName 区域名称
	 * @apiSuccess {String} parentOfficeName 父部门名称
	 * @apiSuccessExample {json} 成功返回结果
	 *   {"code":0,"msg":null,"count":1,"data":{"id":1,"createTime":1531303130000,"updateTime":1531303130000,"delFlag":1,"officeName":"工商局","officeCode":"gsj","parentId":0,"areaId":2,"orderBy":1,"areaName":"建邺区","parentOfficeName":null}}
	 */
	@RequestMapping(value = "/getMessDataForInit", method = RequestMethod.POST)
	public RestServiceResult<List<Map>> getMessDataForInit(HttpServletRequest request) {
		RestServiceResult<List<Map>> result=new RestServiceResult<List<Map>>();
		
		List<Map> list = null;
		list = messDataService.getMessDataForInit();
		String jdToken = HttpServletHelper.getUserToken(request);
		result.setCode(RestServiceResult.CODE_SUCCESS);
		result.setData(list);
		return result;
	}
    
}
